package com.xidian.zhiancloud.service.riskcontrol.riskidenva;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.riskcontrol.riskidenva.TRiskAssessmentMeasuresMapper;
import com.xidian.zhiancloud.dao.riskcontrol.riskidenva.TRiskCheckItemsMapper;
import com.xidian.zhiancloud.dao.riskcontrol.riskpointslist.TEquipFacStatusMapper;
import com.xidian.zhiancloud.model.riskcontrol.TRiskCheckItemsList;
import com.xidian.zhiancloud.model.riskcontrol.entity.TRLedgerStaSS00Entity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 风险管控-风险点清单-设备设施清单-检查项
 */
@Service
public class TRiskCheckItemsService extends ServiceImpl
        <TRiskCheckItemsMapper, TRiskCheckItemsList> {

    @Autowired
    TRiskCheckItemsMapper tRiskCheckItemsMapper;

    @Autowired
    TRiskAssessmentMeasuresMapper tRiskAssessmentMeasuresMapper;
    
    @Autowired
    TEquipFacStatusMapper tEquipFacStatusMapper;

    //风险辨识-风险辨识-添加检查项
    public int insertTRiskCheckItems(TRiskCheckItemsList checkItems){
        return tRiskCheckItemsMapper.insertTRiskCheckItems(checkItems);
    }

    //风险辨识-风险辨识-编辑检查项
    public int updateTRiskCheckItems(String id,TRiskCheckItemsList checkItems){
        return tRiskCheckItemsMapper.updateTRiskCheckItems(Long.valueOf(id),checkItems);
    }

    public List<TRiskCheckItemsList> getById(Long companyId,String taskAllocatId){
        return tRiskCheckItemsMapper.getById(companyId,taskAllocatId);
    }

    public List<TRiskCheckItemsList> getByIds(Long companyId,String id){
        return tRiskCheckItemsMapper.getByIds(companyId,id);
    }

    //风险辨识-风险辨识-删除检查项
    public int deleteTRiskCheckItems(String id){
        List<String> lists = getList(id);
        return tRiskCheckItemsMapper.deleteTRiskCheckItems(lists);
    }

    /**
     * id放入list
     * @param id id(多个已逗号分隔)
     * @return List集合
     */
    public List<String> getList(String id) {
        List<String> list = new ArrayList<String>();
        String[] str = id.split(",");
        for (int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        return list;
    }

    public int addCheckItemsEntity(Long companyId,
                                   Long userId, TRLedgerStaSS00Entity cheItemEnt){
        int res = tRiskCheckItemsMapper.addCheckItemsEntity
            (companyId,String.valueOf(userId),cheItemEnt);
        
        if(res!=0){
            
        }
        return res;
    }

}
